package org.linlinjava.litemall.wx.web;

import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.core.validator.Order;
import org.linlinjava.litemall.core.validator.Sort;
import org.linlinjava.litemall.wx.annotation.LoginUser;
import org.linlinjava.litemall.wx.service.WxRentOrderDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("/wx/rentOrderDetail")
public class WxRentOrderDetailController {
    @Autowired
    private WxRentOrderDetailService wxRentOrderDetailService;

    /**
     * 查询我借过的书
     * @param userId
     * @param page
     * @param limit
     * @param sort
     * @param order
     * @return
     */
    @GetMapping("/borrowedBooks")
    public Object queryMyBorrowed(@LoginUser Integer userId,
                                  @RequestParam(required = false,defaultValue = "1") Integer page,
                                  @RequestParam(required = false,defaultValue = "10") Integer limit,
                                  @Sort @RequestParam(required = false,defaultValue = "add_time") String sort,
                                  @Order @RequestParam(required = false,defaultValue = "desc") String order) {
        if (userId == null) {
            return ResponseUtil.unlogin();
        }
        return ResponseUtil.okList(wxRentOrderDetailService.queryMyBorrowedBook(userId, page, limit, sort, order));
    }
}
